<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/2/16
  Time: 18:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="java.util.List" %>
<%@ page import="com.zhiyou.model.House" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>公寓系统 - 房屋信息管理</title>
	<link rel="stylesheet" href="../../css/main.css">
	<link rel="stylesheet" href="../../lib/font-awesome/css/font-awesome.css">
</head>
<body>
<div class="box">
	<h3>房屋信息管理</h3>
	<div class="actions">
		<div>
			<c:forEach items="${auths}" var="auth">
				<c:if test="${auth.aid==2}">
					<a class="btn btn-primary" href="add.jsp">添加房屋信息</a>
				</c:if>
			</c:forEach>
		</div>
	</div>
	&nbsp;
	<%--模糊查询--%>
	<form action="<c:url value="/user/house"/>" method="get">
		地址 <input type="text" placeholder="请输入房屋地址" name="keyword">
		朝向 <input type="text" placeholder="请输入房屋朝向" name="hdirS">
		价格 <input type="text" placeholder="请输入价格" name="lowprice">
			-<input type="text" placeholder="请输入价格" name="highprice">
			<input type="hidden" name="pageNo" value="1" >
		<input type="submit" value="搜索">
	</form>
	<table class="list">
		<tr>
			<th>序号</th>
			<th>所属地区</th>
			<th>楼层</th>
			<th>房间数</th>
			<th>地址</th>
			<th>朝向</th>
			<th>装修</th>
			<th>空气质量</th>
			<th>价格</th>
			<th>出租状态</th>
			<th>图片</th>
			<th>添加时间</th>
			<th>更新时间</th>
			<th>操作</th>
		</tr>
		<c:forEach items="${houses}" var="house">
			<tr>
				<td>${house.hid}</td>
				<td>${house.haddress}</td>
				<td>${house.hfloor}</td>
				<td>${house.hroomNum}</td>
				<td>${house.harea}</td>
				<td>${house.hdir}</td>
				<td>${house.hdeco}</td>
				<td>${house.hair}</td>
				<td>${house.hprice}</td>
				<td>${house.hrentStatus}</td>
				<td>${house.himage}</td>
				<td>${house.haddTime}</td>
				<td>${house.hupdateTime}</td>
				<td>
					<a class="fa fa-info" title="详情" href="<c:url value="/user/houseUpdate?hid=${house.hid}&detail=1"/>"></a>
					&nbsp;&nbsp;
					<c:forEach items="${auths}" var="auth">
						<c:if test="${auth.aid==3}">
							<a class="fa fa-pencil" title="编辑" href="<c:url value="/user/houseUpdate?hid=${house.hid}"/>"></a>
						</c:if>
					</c:forEach>
					&nbsp;&nbsp;
					<c:forEach items="${auths}" var="auth">
						<c:if test="${auth.aid==4}">
							<a class="fa fa-remove" title="删除"  onclick="confirmDelete(${house.hid})"></a>
						</c:if>
					</c:forEach>
				</td>
			</tr>
		</c:forEach>

		</tr>
	</table>
	<div class="pager-info">
		<div>共有 ${pageUtil.total} 条记录，第 ${pageUtil.pageNo}/${pageUtil.pageNum} 页 </div>
		<div>
			<ul class="pagination">
				<li class="paginate_button previous">
				<a class="${pageUtil.pageNo==1?"disabled":""}" href="<c:url value="/user/house?pageNo=${pageUtil.pageNo-1}&keyword=${keywordMap.keyword}&${keywordMap.hidrS}&${keywordMap.lowprice}&${keywordMap.highprice}"/>">上一页</a>
				</li>
				<c:forEach begin="1" end="${pageUtil.pageNum}" var="i">
				<li class="paginate_button ${pageUtil.pageNo==i?"active":""}"><a href="<c:url value="/user/house?pageNo=${i}&keyword=${keywordMap.keyword}&${keywordMap.hidrS}&${keywordMap.lowprice}&${keywordMap.highprice}"/>">${i}</a></li>
				</c:forEach>
				<li class="paginate_button next">
				<a class="${pageUtil.pageNo==pageUtil.pageNum?"disabled":""}" href="<c:url value="/user/house?pageNo=${pageUtil.pageNo+1}&keyword=${keywordMap.keyword}&${keywordMap.hidrS}&${keywordMap.lowprice}&${keywordMap.highprice}"/>">下一页</a>
				</li>
			</ul>
		</div>
	</div>
</div>
<script src="../../lib/jquery/jquery.js"></script>
<script>
function confirmDelete(id){
	if (confirm("确定要删除吗？")) {
		window.location="<c:url value="/user/houseDelete?hid="/>"+id+"&pageNo="+${pageUtil.pageNo};
	}
	return false;
}
</script>
</body>
</html>